package com.lyf.scm.plan.api.controller;

import com.github.pagehelper.PageInfo;
import com.lyf.scm.plan.api.dto.EsAggregationDTO;
import com.lyf.scm.plan.api.dto.EsReturnDTO;
import com.lyf.scm.plan.domain.service.SalesPlanEsLazyLoadingService;
import com.rome.arch.core.clientobject.Response;
import com.rome.arch.util.controller.RomeController;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

/**
 * es懒加载查询解决方案
 *
 * @author wangchlei
 * @date 2020/11/14
 */
@Slf4j
@RomeController
@Api(tags = "es懒加载查询解决方案")
@RequestMapping("/api/v1/lazyLoading")
public class SalesPlanEsLazyLoadingController {
    @Resource
    private SalesPlanEsLazyLoadingService salesPlanEsLazyLoadingService;

    @PostMapping("/query")
    public Response<PageInfo<EsReturnDTO>> pageQuery(@RequestBody EsAggregationDTO esAggregation) {
        return Response.builderSuccess(salesPlanEsLazyLoadingService.pageQuery(esAggregation));
    }

    @PostMapping("/export")
    public Response<List<EsReturnDTO>> queryFromCache(@RequestBody EsAggregationDTO esAggregationDTO) {
        return Response.builderSuccess(salesPlanEsLazyLoadingService.queryFromCache(esAggregationDTO));
    }
}
